package com.jiepos.mpos.biz.transaction.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.transaction.service.LogTransJYLSService;
import com.jiepos.mpos.common.entity.App_Log_Trans_JnlsEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;
import com.jiepos.mpos.core.util.StringUtils;

/**
 * 
 * 调单查询视图层
 * 
 * @ProjectName: [mpos1]
 * @Package com.jiepos.mpos.biz.transaction.controller
 * @author 肖志伟
 * @version 1.0
 * @since 2017年11月9日 上午11:12:17
 * @history（历次修订内容、修订人、修订时间等） @UpdateRemark [说明本次修改内容]
 * @Copyright (c) 2017 江苏杰博实信息技术有限公司
 */
@Controller
@RequestMapping("logcheckorder")
public class LogCheckOrderController extends BaseController {

	@Autowired
	private LogTransJYLSService logTransJYLSService;

	/**
	 * 调单查询交易流水列表页显示页
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/getTransactionLogList.do")
	public ModelAndView getTransactionLogList(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView modelAndView = new ModelAndView("/module/transaction/checkorderlog/checkorderlog_list");
		return super.getDetail(request, response, modelAndView);
	}

	/**
	 * 调单查询json数据
	 * @param request
	 * @param response
	 * @param jylsEntity
	 * @return
	 */
	@RequestMapping("/getTransactionLogListJson.do")
	@ResponseBody
	public Map getTransactionLogListJson(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination, App_Log_Trans_JnlsEntity jylsEntity, String loc_dt_start, String loc_dt_end,
			String custom_name) {
		return logTransJYLSService.getTransactionLogList1(request, pagination, jylsEntity, loc_dt_start, loc_dt_end,
				custom_name);
	}

	/**
	 * 下载调单查询交易流水数据
	 * 
	 * @param request
	 * @param response
	 * @param jylsEntity
	 * @return
	 */
	@RequestMapping("/exportTransactionLogs.do")
	@ResponseBody
	public void exportTransactionLogs(HttpServletRequest request, HttpServletResponse response, Pagination pagination,
			App_Log_Trans_JnlsEntity jylsEntity, String loc_dt_start, String loc_dt_end, String custom_name,
			String ids) {
		super.clearCookie(request, response);
		String fileName = "DiaoDanChaXun.xls";
		String msg = logTransJYLSService.executeSaveTransLogFile1(request, response, pagination, fileName, jylsEntity,
				loc_dt_start, loc_dt_end, custom_name, ids);
		if (StringUtils.isBlank(msg)) {
			super.setFileParam(request, response, fileName);
		} else {
			super.setErrorFileParam(request, response, msg);
		}
	}

}